/**
 * Tencent is pleased to support the open source community by making Tars available.
 *
 * Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved.
 *
 * Licensed under the BSD 3-Clause License (the "License"); you may not use this file except 
 * in compliance with the License. You may obtain a copy of the License at
 *
 * https://opensource.org/licenses/BSD-3-Clause
 *
 * Unless required by applicable law or agreed to in writing, software distributed 
 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 * specific language governing permissions and limitations under the License.
 */

// **********************************************************************
// This file was generated by a TARS parser!
// TARS version 1.1.0.
// **********************************************************************

#ifndef __TUPDEMO_H_
#define __TUPDEMO_H_

#include <map>
#include <string>
#include <vector>
#include "tup/Tars.h"
using namespace std;
#include "servant/ServantProxy.h"
#include "servant/Servant.h"
#include "promise/promise.h"


namespace TarsTest
{
    struct AddInt : public tars::TarsStructBase
    {
    public:
        static string className()
        {
            return "TarsTest.AddInt";
        }
        static string MD5()
        {
            return "e1393b6da8978c827dfe83d5c359f0c2";
        }
        AddInt()
        :adda(0),addb(0),addStr("this is a add b")
        {
        }
        void resetDefautlt()
        {
            adda = 0;
            addb = 0;
            addStr = "this is a add b";
        }
        template<typename WriterT>
        void writeTo(tars::TarsOutputStream<WriterT>& _os) const
        {
            _os.write(adda, 0);
            _os.write(addb, 1);
            if (addStr != "this is a add b")
            {
                _os.write(addStr, 2);
            }
        }
        template<typename ReaderT>
        void readFrom(tars::TarsInputStream<ReaderT>& _is)
        {
            resetDefautlt();
            _is.read(adda, 0, true);
            _is.read(addb, 1, true);
            _is.read(addStr, 2, false);
        }
        ostream& display(ostream& _os, int _level=0) const
        {
            tars::TarsDisplayer _ds(_os, _level);
            _ds.display(adda,"adda");
            _ds.display(addb,"addb");
            _ds.display(addStr,"addStr");
            return _os;
        }
        ostream& displaySimple(ostream& _os, int _level=0) const
        {
            tars::TarsDisplayer _ds(_os, _level);
            _ds.displaySimple(adda, true);
            _ds.displaySimple(addb, true);
            _ds.displaySimple(addStr, false);
            return _os;
        }
    public:
        tars::Int32 adda;
        tars::Int32 addb;
        std::string addStr;
    };
    inline bool operator==(const AddInt&l, const AddInt&r)
    {
        return l.adda == r.adda && l.addb == r.addb && l.addStr == r.addStr;
    }
    inline bool operator!=(const AddInt&l, const AddInt&r)
    {
        return !(l == r);
    }

    struct Result : public tars::TarsStructBase
    {
    public:
        static string className()
        {
            return "TarsTest.Result";
        }
        static string MD5()
        {
            return "b84e4dd5dd1d7c43dbe702512024405f";
        }
        Result()
        :addResult(0),strResult("")
        {
        }
        void resetDefautlt()
        {
            addResult = 0;
            strResult = "";
        }
        template<typename WriterT>
        void writeTo(tars::TarsOutputStream<WriterT>& _os) const
        {
            _os.write(addResult, 0);
            _os.write(strResult, 1);
        }
        template<typename ReaderT>
        void readFrom(tars::TarsInputStream<ReaderT>& _is)
        {
            resetDefautlt();
            _is.read(addResult, 0, true);
            _is.read(strResult, 1, true);
        }
        ostream& display(ostream& _os, int _level=0) const
        {
            tars::TarsDisplayer _ds(_os, _level);
            _ds.display(addResult,"addResult");
            _ds.display(strResult,"strResult");
            return _os;
        }
        ostream& displaySimple(ostream& _os, int _level=0) const
        {
            tars::TarsDisplayer _ds(_os, _level);
            _ds.displaySimple(addResult, true);
            _ds.displaySimple(strResult, false);
            return _os;
        }
    public:
        tars::Int32 addResult;
        std::string strResult;
    };
    inline bool operator==(const Result&l, const Result&r)
    {
        return l.addResult == r.addResult && l.strResult == r.strResult;
    }
    inline bool operator!=(const Result&l, const Result&r)
    {
        return !(l == r);
    }


    /* callback of async proxy for client */
    class TupDemoPrxCallback: public tars::ServantProxyCallback
    {
    public:
        virtual ~TupDemoPrxCallback(){}
        virtual void callback_aAddb(tars::Int32 ret,  const TarsTest::Result& aAddbResult)
        { throw std::runtime_error("callback_aAddb() override incorrect."); }
        virtual void callback_aAddb_exception(tars::Int32 ret)
        { throw std::runtime_error("callback_aAddb_exception() override incorrect."); }

        virtual void callback_helloWord(tars::Int32 ret,  const std::string& strOut)
        { throw std::runtime_error("callback_helloWord() override incorrect."); }
        virtual void callback_helloWord_exception(tars::Int32 ret)
        { throw std::runtime_error("callback_helloWord_exception() override incorrect."); }

    public:
        virtual const map<std::string, std::string> & getResponseContext() const
        {
            CallbackThreadData * pCbtd = CallbackThreadData::getData();
            assert(pCbtd != NULL);

            if(!pCbtd->getContextValid())
            {
                throw TC_Exception("cann't get response context");
            }
            return pCbtd->getResponseContext();
        }

    public:
        virtual int onDispatch(tars::ReqMessagePtr msg)
        {
            static ::std::string __TupDemo_all[]=
            {
                "aAddb",
                "helloWord"
            };
            pair<string*, string*> r = equal_range(__TupDemo_all, __TupDemo_all+2, string(msg->request.sFuncName));
            if(r.first == r.second) return tars::TARSSERVERNOFUNCERR;
            switch(r.first - __TupDemo_all)
            {
                case 0:
                {
                    if (msg->response.iRet != tars::TARSSERVERSUCCESS)
                    {
                        callback_aAddb_exception(msg->response.iRet);

                        return msg->response.iRet;
                    }
                    tars::TarsInputStream<tars::BufferReader> _is;

                    _is.setBuffer(msg->response.sBuffer);
                    tars::Int32 _ret;
                    _is.read(_ret, 0, true);

                    TarsTest::Result aAddbResult;
                    _is.read(aAddbResult, 2, true);
                    CallbackThreadData * pCbtd = CallbackThreadData::getData();
                    assert(pCbtd != NULL);

                    pCbtd->setResponseContext(msg->response.context);

                    callback_aAddb(_ret, aAddbResult);

                    pCbtd->delResponseContext();

                    return tars::TARSSERVERSUCCESS;

                }
                case 1:
                {
                    if (msg->response.iRet != tars::TARSSERVERSUCCESS)
                    {
                        callback_helloWord_exception(msg->response.iRet);

                        return msg->response.iRet;
                    }
                    tars::TarsInputStream<tars::BufferReader> _is;

                    _is.setBuffer(msg->response.sBuffer);
                    tars::Int32 _ret;
                    _is.read(_ret, 0, true);

                    std::string strOut;
                    _is.read(strOut, 2, true);
                    CallbackThreadData * pCbtd = CallbackThreadData::getData();
                    assert(pCbtd != NULL);

                    pCbtd->setResponseContext(msg->response.context);

                    callback_helloWord(_ret, strOut);

                    pCbtd->delResponseContext();

                    return tars::TARSSERVERSUCCESS;

                }
            }
            return tars::TARSSERVERNOFUNCERR;
        }

    };
    typedef tars::TC_AutoPtr<TupDemoPrxCallback> TupDemoPrxCallbackPtr;

    /* callback of promise async proxy for client */
    class TupDemoPrxCallbackPromise: public tars::ServantProxyCallback
    {
    public:
        virtual ~TupDemoPrxCallbackPromise(){}
    public:
        struct PromiseaAddb: virtual public TC_HandleBase
        {
        public:
            tars::Int32 _ret;
            TarsTest::Result aAddbResult;
            map<std::string, std::string> _mRspContext;
        };
        
        typedef tars::TC_AutoPtr< TupDemoPrxCallbackPromise::PromiseaAddb > PromiseaAddbPtr;

        TupDemoPrxCallbackPromise(const promise::Promise< TupDemoPrxCallbackPromise::PromiseaAddbPtr > &promise)
        : _promise_aAddb(promise)
        {}
        
        virtual void callback_aAddb(const TupDemoPrxCallbackPromise::PromiseaAddbPtr &ptr)
        {
            _promise_aAddb.setValue(ptr);
        }
        virtual void callback_aAddb_exception(tars::Int32 ret)
        {
            std::string str("");
            str += "Function:aAddb_exception|Ret:";
            str += TC_Common::tostr(ret);
            _promise_aAddb.setException(promise::copyException(str, ret));
        }

    protected:
        promise::Promise< TupDemoPrxCallbackPromise::PromiseaAddbPtr > _promise_aAddb;

    public:
        struct PromisehelloWord: virtual public TC_HandleBase
        {
        public:
            tars::Int32 _ret;
            std::string strOut;
            map<std::string, std::string> _mRspContext;
        };
        
        typedef tars::TC_AutoPtr< TupDemoPrxCallbackPromise::PromisehelloWord > PromisehelloWordPtr;

        TupDemoPrxCallbackPromise(const promise::Promise< TupDemoPrxCallbackPromise::PromisehelloWordPtr > &promise)
        : _promise_helloWord(promise)
        {}
        
        virtual void callback_helloWord(const TupDemoPrxCallbackPromise::PromisehelloWordPtr &ptr)
        {
            _promise_helloWord.setValue(ptr);
        }
        virtual void callback_helloWord_exception(tars::Int32 ret)
        {
            std::string str("");
            str += "Function:helloWord_exception|Ret:";
            str += TC_Common::tostr(ret);
            _promise_helloWord.setException(promise::copyException(str, ret));
        }

    protected:
        promise::Promise< TupDemoPrxCallbackPromise::PromisehelloWordPtr > _promise_helloWord;

    public:
        virtual int onDispatch(tars::ReqMessagePtr msg)
        {
            static ::std::string __TupDemo_all[]=
            {
                "aAddb",
                "helloWord"
            };

            pair<string*, string*> r = equal_range(__TupDemo_all, __TupDemo_all+2, string(msg->request.sFuncName));
            if(r.first == r.second) return tars::TARSSERVERNOFUNCERR;
            switch(r.first - __TupDemo_all)
            {
                case 0:
                {
                    if (msg->response.iRet != tars::TARSSERVERSUCCESS)
                    {
                        callback_aAddb_exception(msg->response.iRet);

                        return msg->response.iRet;
                    }
                    tars::TarsInputStream<tars::BufferReader> _is;

                    _is.setBuffer(msg->response.sBuffer);

                    TupDemoPrxCallbackPromise::PromiseaAddbPtr ptr = new TupDemoPrxCallbackPromise::PromiseaAddb();

                    try
                    {
                        _is.read(ptr->_ret, 0, true);

                        _is.read(ptr->aAddbResult, 2, true);
                    }
                    catch(std::exception &ex)
                    {
                        callback_aAddb_exception(tars::TARSCLIENTDECODEERR);

                        return tars::TARSCLIENTDECODEERR;
                    }
                    catch(...)
                    {
                        callback_aAddb_exception(tars::TARSCLIENTDECODEERR);

                        return tars::TARSCLIENTDECODEERR;
                    }

                    ptr->_mRspContext = msg->response.context;

                    callback_aAddb(ptr);

                    return tars::TARSSERVERSUCCESS;

                }
                case 1:
                {
                    if (msg->response.iRet != tars::TARSSERVERSUCCESS)
                    {
                        callback_helloWord_exception(msg->response.iRet);

                        return msg->response.iRet;
                    }
                    tars::TarsInputStream<tars::BufferReader> _is;

                    _is.setBuffer(msg->response.sBuffer);

                    TupDemoPrxCallbackPromise::PromisehelloWordPtr ptr = new TupDemoPrxCallbackPromise::PromisehelloWord();

                    try
                    {
                        _is.read(ptr->_ret, 0, true);

                        _is.read(ptr->strOut, 2, true);
                    }
                    catch(std::exception &ex)
                    {
                        callback_helloWord_exception(tars::TARSCLIENTDECODEERR);

                        return tars::TARSCLIENTDECODEERR;
                    }
                    catch(...)
                    {
                        callback_helloWord_exception(tars::TARSCLIENTDECODEERR);

                        return tars::TARSCLIENTDECODEERR;
                    }

                    ptr->_mRspContext = msg->response.context;

                    callback_helloWord(ptr);

                    return tars::TARSSERVERSUCCESS;

                }
            }
            return tars::TARSSERVERNOFUNCERR;
        }

    };
    typedef tars::TC_AutoPtr<TupDemoPrxCallbackPromise> TupDemoPrxCallbackPromisePtr;

    /* callback of coroutine async proxy for client */
    class TupDemoCoroPrxCallback: public TupDemoPrxCallback
    {
    public:
        virtual ~TupDemoCoroPrxCallback(){}
    public:
        virtual const map<std::string, std::string> & getResponseContext() const { return _mRspContext; }

        virtual void setResponseContext(const map<std::string, std::string> &mContext) { _mRspContext = mContext; }

    public:
        int onDispatch(tars::ReqMessagePtr msg)
        {
            static ::std::string __TupDemo_all[]=
            {
                "aAddb",
                "helloWord"
            };

            pair<string*, string*> r = equal_range(__TupDemo_all, __TupDemo_all+2, string(msg->request.sFuncName));
            if(r.first == r.second) return tars::TARSSERVERNOFUNCERR;
            switch(r.first - __TupDemo_all)
            {
                case 0:
                {
                    if (msg->response.iRet != tars::TARSSERVERSUCCESS)
                    {
                        callback_aAddb_exception(msg->response.iRet);

                        return msg->response.iRet;
                    }
                    tars::TarsInputStream<tars::BufferReader> _is;

                    _is.setBuffer(msg->response.sBuffer);
                    try
                    {
                        tars::Int32 _ret;
                        _is.read(_ret, 0, true);

                        TarsTest::Result aAddbResult;
                        _is.read(aAddbResult, 2, true);
                        setResponseContext(msg->response.context);

                        callback_aAddb(_ret, aAddbResult);

                    }
                    catch(std::exception &ex)
                    {
                        callback_aAddb_exception(tars::TARSCLIENTDECODEERR);

                        return tars::TARSCLIENTDECODEERR;
                    }
                    catch(...)
                    {
                        callback_aAddb_exception(tars::TARSCLIENTDECODEERR);

                        return tars::TARSCLIENTDECODEERR;
                    }

                    return tars::TARSSERVERSUCCESS;

                }
                case 1:
                {
                    if (msg->response.iRet != tars::TARSSERVERSUCCESS)
                    {
                        callback_helloWord_exception(msg->response.iRet);

                        return msg->response.iRet;
                    }
                    tars::TarsInputStream<tars::BufferReader> _is;

                    _is.setBuffer(msg->response.sBuffer);
                    try
                    {
                        tars::Int32 _ret;
                        _is.read(_ret, 0, true);

                        std::string strOut;
                        _is.read(strOut, 2, true);
                        setResponseContext(msg->response.context);

                        callback_helloWord(_ret, strOut);

                    }
                    catch(std::exception &ex)
                    {
                        callback_helloWord_exception(tars::TARSCLIENTDECODEERR);

                        return tars::TARSCLIENTDECODEERR;
                    }
                    catch(...)
                    {
                        callback_helloWord_exception(tars::TARSCLIENTDECODEERR);

                        return tars::TARSCLIENTDECODEERR;
                    }

                    return tars::TARSSERVERSUCCESS;

                }
            }
            return tars::TARSSERVERNOFUNCERR;
        }

    protected:
        map<std::string, std::string> _mRspContext;
    };
    typedef tars::TC_AutoPtr<TupDemoCoroPrxCallback> TupDemoCoroPrxCallbackPtr;

    /* proxy for client */
    class TupDemoProxy : public tars::ServantProxy
    {
    public:
        typedef map<string, string> TARS_CONTEXT;
        tars::Int32 aAddb(const TarsTest::AddInt & addData,TarsTest::Result &aAddbResult,const map<string, string> &context = TARS_CONTEXT(),map<string, string> * pResponseContext = NULL)
        {
            tars::TarsOutputStream<tars::BufferWriter> _os;
            _os.write(addData, 1);
            _os.write(aAddbResult, 2);
            tars::ResponsePacket rep;
            std::map<string, string> _mStatus;
            tars_invoke(tars::TARSNORMAL,"aAddb", _os.getByteBuffer(), context, _mStatus, rep);
            if(pResponseContext)
            {
                *pResponseContext = rep.context;
            }

            tars::TarsInputStream<tars::BufferReader> _is;
            _is.setBuffer(rep.sBuffer);
            tars::Int32 _ret;
            _is.read(_ret, 0, true);
            _is.read(aAddbResult, 2, true);
            return _ret;
        }

        void async_aAddb(TupDemoPrxCallbackPtr callback,const TarsTest::AddInt &addData,const map<string, string>& context = TARS_CONTEXT())
        {
            tars::TarsOutputStream<tars::BufferWriter> _os;
            _os.write(addData, 1);
            std::map<string, string> _mStatus;
            tars_invoke_async(tars::TARSNORMAL,"aAddb", _os.getByteBuffer(), context, _mStatus, callback);
        }
        
        promise::Future< TupDemoPrxCallbackPromise::PromiseaAddbPtr > promise_async_aAddb(const TarsTest::AddInt &addData,const map<string, string>& context)
        {
            promise::Promise< TupDemoPrxCallbackPromise::PromiseaAddbPtr > promise;
            TupDemoPrxCallbackPromisePtr callback = new TupDemoPrxCallbackPromise(promise);

            tars::TarsOutputStream<tars::BufferWriter> _os;
            _os.write(addData, 1);
            std::map<string, string> _mStatus;
            tars_invoke_async(tars::TARSNORMAL,"aAddb", _os.getByteBuffer(), context, _mStatus, callback);

            return promise.getFuture();
        }

        void coro_aAddb(TupDemoCoroPrxCallbackPtr callback,const TarsTest::AddInt &addData,const map<string, string>& context = TARS_CONTEXT())
        {
            tars::TarsOutputStream<tars::BufferWriter> _os;
            _os.write(addData, 1);
            std::map<string, string> _mStatus;
            tars_invoke_async(tars::TARSNORMAL,"aAddb", _os.getByteBuffer(), context, _mStatus, callback, true);
        }

        tars::Int32 helloWord(const std::string & strIn,std::string &strOut,const map<string, string> &context = TARS_CONTEXT(),map<string, string> * pResponseContext = NULL)
        {
            tars::TarsOutputStream<tars::BufferWriter> _os;
            _os.write(strIn, 1);
            _os.write(strOut, 2);
            tars::ResponsePacket rep;
            std::map<string, string> _mStatus;
            tars_invoke(tars::TARSNORMAL,"helloWord", _os.getByteBuffer(), context, _mStatus, rep);
            if(pResponseContext)
            {
                *pResponseContext = rep.context;
            }

            tars::TarsInputStream<tars::BufferReader> _is;
            _is.setBuffer(rep.sBuffer);
            tars::Int32 _ret;
            _is.read(_ret, 0, true);
            _is.read(strOut, 2, true);
            return _ret;
        }

        void async_helloWord(TupDemoPrxCallbackPtr callback,const std::string &strIn,const map<string, string>& context = TARS_CONTEXT())
        {
            tars::TarsOutputStream<tars::BufferWriter> _os;
            _os.write(strIn, 1);
            std::map<string, string> _mStatus;
            tars_invoke_async(tars::TARSNORMAL,"helloWord", _os.getByteBuffer(), context, _mStatus, callback);
        }
        
        promise::Future< TupDemoPrxCallbackPromise::PromisehelloWordPtr > promise_async_helloWord(const std::string &strIn,const map<string, string>& context)
        {
            promise::Promise< TupDemoPrxCallbackPromise::PromisehelloWordPtr > promise;
            TupDemoPrxCallbackPromisePtr callback = new TupDemoPrxCallbackPromise(promise);

            tars::TarsOutputStream<tars::BufferWriter> _os;
            _os.write(strIn, 1);
            std::map<string, string> _mStatus;
            tars_invoke_async(tars::TARSNORMAL,"helloWord", _os.getByteBuffer(), context, _mStatus, callback);

            return promise.getFuture();
        }

        void coro_helloWord(TupDemoCoroPrxCallbackPtr callback,const std::string &strIn,const map<string, string>& context = TARS_CONTEXT())
        {
            tars::TarsOutputStream<tars::BufferWriter> _os;
            _os.write(strIn, 1);
            std::map<string, string> _mStatus;
            tars_invoke_async(tars::TARSNORMAL,"helloWord", _os.getByteBuffer(), context, _mStatus, callback, true);
        }

        TupDemoProxy* tars_hash(int64_t key)
        {
            return (TupDemoProxy*)ServantProxy::tars_hash(key);
        }

        TupDemoProxy* tars_consistent_hash(int64_t key)
        {
            return (TupDemoProxy*)ServantProxy::tars_consistent_hash(key);
        }

        TupDemoProxy* tars_set_timeout(int msecond)
        {
            return (TupDemoProxy*)ServantProxy::tars_set_timeout(msecond);
        }

    };
    typedef tars::TC_AutoPtr<TupDemoProxy> TupDemoPrx;

    /* servant for server */
    class TupDemo : public tars::Servant
    {
    public:
        virtual ~TupDemo(){}
        virtual tars::Int32 aAddb(const TarsTest::AddInt & addData,TarsTest::Result &aAddbResult,tars::TarsCurrentPtr current) = 0;
        static void async_response_aAddb(tars::TarsCurrentPtr current, tars::Int32 _ret, const TarsTest::Result &aAddbResult)
        {
            if (current->getRequestVersion() == TUPVERSION )
            {
                UniAttribute<tars::BufferWriter, tars::BufferReader>  tarsAttr;
                tarsAttr.setVersion(current->getRequestVersion());
                tarsAttr.put("", _ret);
                tarsAttr.put("aAddbResult", aAddbResult);

                vector<char> sTupResponseBuffer;
                tarsAttr.encode(sTupResponseBuffer);
                current->sendResponse(tars::TARSSERVERSUCCESS, sTupResponseBuffer);
            }
            else
            {
                tars::TarsOutputStream<tars::BufferWriter> _os;
                _os.write(_ret, 0);

                _os.write(aAddbResult, 2);

                current->sendResponse(tars::TARSSERVERSUCCESS, _os.getByteBuffer());
            }
        }

        virtual tars::Int32 helloWord(const std::string & strIn,std::string &strOut,tars::TarsCurrentPtr current) = 0;
        static void async_response_helloWord(tars::TarsCurrentPtr current, tars::Int32 _ret, const std::string &strOut)
        {
            if (current->getRequestVersion() == TUPVERSION )
            {
                UniAttribute<tars::BufferWriter, tars::BufferReader>  tarsAttr;
                tarsAttr.setVersion(current->getRequestVersion());
                tarsAttr.put("", _ret);
                tarsAttr.put("strOut", strOut);

                vector<char> sTupResponseBuffer;
                tarsAttr.encode(sTupResponseBuffer);
                current->sendResponse(tars::TARSSERVERSUCCESS, sTupResponseBuffer);
            }
            else
            {
                tars::TarsOutputStream<tars::BufferWriter> _os;
                _os.write(_ret, 0);

                _os.write(strOut, 2);

                current->sendResponse(tars::TARSSERVERSUCCESS, _os.getByteBuffer());
            }
        }

    public:
        int onDispatch(tars::TarsCurrentPtr _current, vector<char> &_sResponseBuffer)
        {
            static ::std::string __TarsTest__TupDemo_all[]=
            {
                "aAddb",
                "helloWord"
            };

            pair<string*, string*> r = equal_range(__TarsTest__TupDemo_all, __TarsTest__TupDemo_all+2, _current->getFuncName());
            if(r.first == r.second) return tars::TARSSERVERNOFUNCERR;
            switch(r.first - __TarsTest__TupDemo_all)
            {
                case 0:
                {
                    tars::TarsInputStream<tars::BufferReader> _is;
                    _is.setBuffer(_current->getRequestBuffer());
                    TarsTest::AddInt addData;
                    TarsTest::Result aAddbResult;
                    if (_current->getRequestVersion() == TUPVERSION)
                    {
                        UniAttribute<tars::BufferWriter, tars::BufferReader>  tarsAttr;
                        tarsAttr.setVersion(_current->getRequestVersion());
                        tarsAttr.decode(_current->getRequestBuffer());
                        tarsAttr.get("addData", addData);
                        tarsAttr.getByDefault("aAddbResult", aAddbResult, aAddbResult);
                    }
                    else
                    {
                        _is.read(addData, 1, true);
                        _is.read(aAddbResult, 2, false);
                    }
                    tars::Int32 _ret = aAddb(addData,aAddbResult, _current);
                    if(_current->isResponse())
                    {
                        if (_current->getRequestVersion() == TUPVERSION )
                        {
                            UniAttribute<tars::BufferWriter, tars::BufferReader>  tarsAttr;
                            tarsAttr.setVersion(_current->getRequestVersion());
                            tarsAttr.put("", _ret);
                            tarsAttr.put("aAddbResult", aAddbResult);
                            tarsAttr.encode(_sResponseBuffer);
                        }
                        else
                        {
                            tars::TarsOutputStream<tars::BufferWriter> _os;
                            _os.write(_ret, 0);
                            _os.write(aAddbResult, 2);
                            _os.swap(_sResponseBuffer);
                        }
                    }
                    return tars::TARSSERVERSUCCESS;

                }
                case 1:
                {
                    tars::TarsInputStream<tars::BufferReader> _is;
                    _is.setBuffer(_current->getRequestBuffer());
                    std::string strIn;
                    std::string strOut;
                    if (_current->getRequestVersion() == TUPVERSION)
                    {
                        UniAttribute<tars::BufferWriter, tars::BufferReader>  tarsAttr;
                        tarsAttr.setVersion(_current->getRequestVersion());
                        tarsAttr.decode(_current->getRequestBuffer());
                        tarsAttr.get("strIn", strIn);
                        tarsAttr.getByDefault("strOut", strOut, strOut);
                    }
                    else
                    {
                        _is.read(strIn, 1, true);
                        _is.read(strOut, 2, false);
                    }
                    tars::Int32 _ret = helloWord(strIn,strOut, _current);
                    if(_current->isResponse())
                    {
                        if (_current->getRequestVersion() == TUPVERSION )
                        {
                            UniAttribute<tars::BufferWriter, tars::BufferReader>  tarsAttr;
                            tarsAttr.setVersion(_current->getRequestVersion());
                            tarsAttr.put("", _ret);
                            tarsAttr.put("strOut", strOut);
                            tarsAttr.encode(_sResponseBuffer);
                        }
                        else
                        {
                            tars::TarsOutputStream<tars::BufferWriter> _os;
                            _os.write(_ret, 0);
                            _os.write(strOut, 2);
                            _os.swap(_sResponseBuffer);
                        }
                    }
                    return tars::TARSSERVERSUCCESS;

                }
            }
            return tars::TARSSERVERNOFUNCERR;
        }
    };


}



#endif
